package ui.panels.commands;

import org.apache.log4j.Logger;

import ui.flowManager.FileReader;
import ui.flowManager.FlowManagerImpl;

/**
 * @author vladimir && alon
 *
 *
 */
public class ReadFromFileCommand implements Command{
	
	private String fileName = null;
	Logger log = Logger.getLogger(this.getClass());
	
	/** Default CTOR*/
	public ReadFromFileCommand(){}
	
	/**
	 *  CTOR
	 *  @param name 
	 */
	public ReadFromFileCommand(String fileName)
	{
		this.fileName = fileName;
	}
	
	/**
	 * Setter of the file name
	 * @param fileName
	 */
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	/**
	 *  Execute the file reader 
	 */
	public void execute(){
		FileReader reader = FileReader.getInstance();
		
		//case the file name was updated
		if(fileName != null)
		{
			log.debug("Read From File Command execute");
			reader.setFileName(fileName);
			reader.readData();	
			
		}
		//case the file name not updated
		else
		{
			log.debug("Fail in execute Read From File Command - fileName not updated");
		}
		
	}

}
